package com.flower.salary.controller;

import com.flower.salary.common.utils.R;
import com.flower.salary.domain.bo.DeptInfoBO;
import com.flower.salary.domain.entity.SysDept;
import com.flower.salary.service.SysDeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author lavender
 * @version 1.0
 * @date 2024-01-20 21:27
 */
@RestController
@RequestMapping("/dept")
public class SysDeptController {


    @Autowired
    private SysDeptService sysDeptService;

    @GetMapping("/all")
    public R queryAll(){

        List<SysDept> sysDepts = sysDeptService.queryAll();

        return R.ok(sysDepts);


    }


    @PostMapping("/updeteDept")
    public R updateDeptInfo(@RequestBody DeptInfoBO infoBO){
        sysDeptService.updateDeptInfo(infoBO);
        return R.ok("修改成功");
    }

    @PostMapping("/createDept")
    public R createDept(@RequestBody DeptInfoBO infoBO){

        sysDeptService.createDept(infoBO);
        return R.ok("创建部门成功");
    }


    @GetMapping("/delete")
    public R deleteDept(@RequestParam String id){

        sysDeptService.deleteDept(id);
        return R.ok("删除部门成功");
    }

}
